home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
- #
- # $Id: movetree,v 1.5 1994/02/22 21:49:46 carlson Exp $
- #
- # movetree Move a directory tree from one file system to another.
- #
- # Synopsis:
- # movetree [-v] [-n] <source-full-path> [<destination-full-path>]
- #
- # Where:
- # -v Use v option on tar.
- # -n Don't delete the source when done.
- # <source-full-path> The full path of the top source directory
- # to move.
- # <destination-full-path> The full path of the destination directory
- # into which to move. If the directory
- # doesn't exist, it is created. If this
- # option is not provided, . is assumed.
- #
- # Revision History:
- # $Log: movetree,v $
- # Revision 1.5 1994/02/22 21:49:46 carlson
- # Added 'p' flag to tar command. This restores files to their original
- # modes and ignores the present umask.
- #
- # Revision 1.4 1993/08/20 13:13:30 carlson
- # Added better usage info.
- # Added B option to tar commands.
- # Used $options in tar command.
- # If a problem occurs or -n specified, don't remove original directory.
- #
- # Revision 1.3 93/01/22 12:33:33 carlson
- # Modified to have an option that will not remove the source directory
- # when completed.
- #
- # Revision 1.2 92/01/22 15:22:35 carlson
- # Added RCS symbols.
- # If no parameters passed, print a quick help message.
- #
- #-------------------------------------------------------------------------
-
- if ( "$1" == "" ) then
- echo "Usage: movetree [-v] [-n] <source-path> [<destination-path>]"
- echo " -v Use v option on tar."
- echo " -n Don't delete the source when done."
- echo " <source-path> Is the full path to the directory to be"
- echo " moved."
- echo " <destination-path> Is the path to the directory where the"
- echo " source directory is to be moved. If not"
- echo " provided, assumes the current directory."
- exit 0
- endif
-
- set options = "xpBRf"
- set remove = 1
-
- set argv = `getopt nv $*`
- while ( "$1" != "--" )
- switch ( $1 )
- case "-n":
- set remove = 0
- shift
- breaksw
- case "-v":
- set options = "xvpBRf"
- shift
- breaksw
- endsw
- end
- shift
-
- set srcdir = $1:h
- set srcfil = $1:t
-
- set fixdd = 0
- if ( "$2" == "" ) then
- set dstdir = `pwd`
- else
- set dstdir = $2
- if ( ! -e $dstdir ) then
- set dstdir = $2:h
- set fixdd = 1
- endif
- endif
-
- (cd $srcdir ; tar cBf - $srcfil) | (cd $dstdir ; tar $options -)
- set problem = $status
-
- if ( $fixdd ) mv $dstdir/$srcfil $2
-
- if ( $problem == 0 && $remove == 1 ) rm -rf $1
-